package controller;

import view.View;
import model.Model;

import java.util.Observable;
import java.util.Observer;

public class Presenter implements Observer {
	
	View ui;
	Model model;
	
	public Presenter(Model model,View ui) {
		this.model = model;
		this.ui = ui;
	}
	public void update(Observable o, Object arg) {
		if (o == model){
			ui.displayData(model.getData());
		}
		else if (o == ui){
			int command = ui.getUserCommand();
			if (command == 1){
				model.moveUp();
			}
			if (command == 2){
				model.moveDown();
			}
			if (command == 3){
				model.moveRight();
			}
			if (command == 4){
				model.moveLeft();
			}
		}
		
	}


}



